import request from '@/utils/request'

// 获取售后订单列表
export function pageAfterSale(query) {
  return request({
    url: '/order/afterSale/paging',
    method: 'get',
    params: query
  })
}

// 统计售后订单情况
export function statAfterSale(query) {
  return request({
    url: '/order/afterSale/statAfterSale',
    method: 'get',
    params: query
  })
}

// 售后申请详情
export function getAfterSale(afterSaleId, supplierId, warehouseId) {
  return request({
    url: '/order/afterSale/get',
    method: 'get',
    params: { afterSaleId, supplierId, warehouseId }
  })
}

// 保存售后请求
export function updateAfterSale(afterSale) {
  return request({
    url: '/order/afterSale/save',
    method: 'post',
    data: afterSale
  })
}

// 同意退货
export function doAgreeAfterSale(afterSale) {
  return request({
    url: '/order/afterSale/doAgreeAfterSale',
    method: 'post',
    data: afterSale
  })
}

// 供应商同意退货
export function doSupplierAgreeAfterSale(afterSale) {
  return request({
    url: '/order/afterSale/doSupplierAgreeAfterSale',
    method: 'post',
    params: afterSale
  })
}

// 确认收货
export function doReceiveGoods(afterSale) {
  return request({
    url: '/order/afterSale/doReceiveGoods',
    method: 'post',
    params: afterSale
  })
}

// 不同意退货
export function doRejectRefund(afterSale) {
  return request({
    url: '/order/afterSale/doRejectRefund',
    method: 'post',
    params: afterSale
  })
}

// 确认退款
export function doRefundMoney(afterSale) {
  return request({
    url: '/order/afterSale/doRefundMoney',
    method: 'post',
    params: afterSale
  })
}

// 提交平台审核
export function addApply(afterSaleId) {
  return request({
    url: '/order/afterSale/addApply',
    method: 'post',
    params: { afterSaleId }
  })
}

// 同意退货之前检查订单商品的审核状态 3.9.3 by wuwei
// 3.9.5废弃, 售后子订单已是独立,只对子售后单做操作
export function checkAfterSaleAuditStatus(afterSaleId) {
  return request({
    url: '/order/afterSale/checkAfterSaleAuditStatus',
    method: 'post',
    params: { afterSaleId }
  })
}

// 保存售后仓
export function doSaveAfterSaleWarehouse(data) {
  return request({
    url: '/order/afterSale/saveAfterSaleWarehouse',
    method: 'post',
    params: data
  })
}

// 确认售后仓
export function doConfirmAfterSaleWarehouse(data) {
  return request({
    url: '/order/afterSale/confirmAfterSaleWarehouse',
    method: 'post',
    params: data
  })
}

// 保存退货入库数量
export function doEditInWarehouseNum(data) {
  return request({
    url: '/order/afterSale/editInWarehouseNum',
    method: 'post',
    params: data
  })
}

// 商品入库，同意退款
export function inWarehouseAndAgree(data) {
  return request({
    url: '/order/afterSale/inWarehouseAndAgree',
    method: 'post',
    params: data
  })
}

// 商品不入库，同意退款
export function unInWarehouseAndAgree(data) {
  return request({
    url: '/order/afterSale/unInWarehouseAndAgree',
    method: 'post',
    params: data
  })
}

// 售后页面按钮操作权限检查
export function checkAfterSaleOperationButtonJurisdiction(afterSaleId, enterpriseId, supplierId, warehouseId) {
  return request({
    url: '/order/afterSale/checkAfterSaleOperationButtonJurisdiction',
    method: 'get',
    params: { afterSaleId, enterpriseId, warehouseId, supplierId }
  })
}
